589c82ea32465e9f22763ab2e32675ed47dd938b,org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/definitions/Definitions.java,Definitions,updateSyntax,#TTCN3ReparseUpdater#List#List#ControlPart#,585

Before Change


		int result = 0;
		boolean enveloped = false;
		int nofDamaged = 0;
		int leftBoundary = location.getOffset() + 1;
		int rightBoundary = location.getEndOffset() - 1;
		final int damageOffset = reparser.getDamageStart();
		final int damageEndOffset = reparser.getDamageEnd();
		IAppendableSyntax lastAppendableBeforeChange = null;
		IAppendableSyntax lastPrependableBeforeChange = null;
		boolean isControlPossible = controlpart == null;

		if (controlpart != null) {
			final Location tempLocation = controlpart.getLocation();
			if (reparser.envelopsDamage(tempLocation)) {
				enveloped = true;
			} else if (!reparser.isDamaged(tempLocation)) {
				if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
					leftBoundary = tempLocation.getEndOffset() + 1;
					lastAppendableBeforeChange = controlpart;
				}
				if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
					rightBoundary = tempLocation.getOffset() - 1;
					lastPrependableBeforeChange = controlpart;
				}
			}
		}

		for (int i = 0, size = groups.size(); i < size && !enveloped; i++) {
			final Group tempGroup = groups.get(i);
			final Location tempLocation = tempGroup.getLocation();
			if (reparser.envelopsDamage(tempLocation)) {
				enveloped = true;
				leftBoundary = tempLocation.getOffset();
				rightBoundary = tempLocation.getEndOffset();
			} else if (reparser.isDamaged(tempLocation)) {
				nofDamaged++;
			} else {
				if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
					leftBoundary = tempLocation.getEndOffset() + 1;
					lastAppendableBeforeChange = tempGroup;
				}
				if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
					rightBoundary = tempLocation.getOffset() - 1;
					lastPrependableBeforeChange = tempGroup;
				}
			}
		}
		if (!groups.isEmpty()) {
			isControlPossible &= groups.get(groups.size() - 1).getLocation().getEndOffset() <= leftBoundary;
		}

		for (int i = 0, size = importedModules.size(); i < size && !enveloped; i++) {
			final ImportModule tempImport = importedModules.get(i);
			if (tempImport.getParentGroup() == null) {
				final Location tempLocation = tempImport.getLocation();
				if (reparser.envelopsDamage(tempLocation)) {
					enveloped = true;
					leftBoundary = tempLocation.getOffset();
					rightBoundary = tempLocation.getEndOffset();
				} else if (reparser.isDamaged(tempLocation)) {
					nofDamaged++;
				} else {
					if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
						leftBoundary = tempLocation.getEndOffset() + 1;
						lastAppendableBeforeChange = tempImport;
					}
					if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
						rightBoundary = tempLocation.getOffset() - 1;
						lastPrependableBeforeChange = tempImport;
					}
				}
			}
		}
		if (!importedModules.isEmpty()) {
			isControlPossible &= importedModules.get(importedModules.size() - 1).getLocation().getEndOffset() <= leftBoundary;
		}

		for (int i = 0, size = friendModules.size(); i < size && !enveloped; i++) {
			final FriendModule tempFriend = friendModules.get(i);
			if (tempFriend.getParentGroup() == null) {
				final Location tempLocation = tempFriend.getLocation();
				if (reparser.envelopsDamage(tempLocation)) {
					enveloped = true;
					leftBoundary = tempLocation.getOffset();
					rightBoundary = tempLocation.getEndOffset();
				} else if (reparser.isDamaged(tempLocation)) {
					nofDamaged++;
				} else {
					if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
						leftBoundary = tempLocation.getEndOffset() + 1;
						lastAppendableBeforeChange = tempFriend;
					}
					if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
						rightBoundary = tempLocation.getOffset() - 1;
						lastPrependableBeforeChange = tempFriend;
					}
				}
			}
		}
		if (!friendModules.isEmpty()) {
			isControlPossible &= friendModules.get(friendModules.size() - 1).getLocation().getEndOffset() <= leftBoundary;
		}

		for (Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext() && !enveloped;) {
			final Definition temp = iterator.next();
			if (temp.getParentGroup() == null) {
				final Location tempLocation = temp.getLocation();
				final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
				if (tempLocation.equals(cumulativeLocation) && reparser.envelopsDamage(cumulativeLocation)) {
					enveloped = true;
					leftBoundary = cumulativeLocation.getOffset();
					rightBoundary = cumulativeLocation.getEndOffset();
				} else if (reparser.isDamaged(cumulativeLocation)) {
					nofDamaged++;
					if (reparser.getDamageStart() == cumulativeLocation.getEndOffset()) {
						lastAppendableBeforeChange = temp;
					} else if (reparser.getDamageEnd() == cumulativeLocation.getOffset()) {
						lastPrependableBeforeChange = temp;
					}
				} else {
					if (cumulativeLocation.getEndOffset() < damageOffset && cumulativeLocation.getEndOffset() > leftBoundary) {
						leftBoundary = cumulativeLocation.getEndOffset() + 1;
						lastAppendableBeforeChange = temp;
					}
					if (cumulativeLocation.getOffset() > damageEndOffset && cumulativeLocation.getOffset() < rightBoundary) {

After Change


					nofDamaged++;
				} else {
					if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
						leftBoundary = tempLocation.getEndOffset();
						lastAppendableBeforeChange = tempImport;
					}
					if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
						rightBoundary = tempLocation.getOffset();
						lastPrependableBeforeChange = tempImport;
					}
				}
			}
		}
		if (!importedModules.isEmpty()) {
			isControlPossible &= importedModules.get(importedModules.size() - 1).getLocation().getEndOffset() < leftBoundary;
		}

		for (int i = 0, size = friendModules.size(); i < size && !enveloped; i++) {
			final FriendModule tempFriend = friendModules.get(i);
			if (tempFriend.getParentGroup() == null) {
				final Location tempLocation = tempFriend.getLocation();
				if (reparser.envelopsDamage(tempLocation)) {
					enveloped = true;
					leftBoundary = tempLocation.getOffset();
					rightBoundary = tempLocation.getEndOffset();
				} else if (reparser.isDamaged(tempLocation)) {
					nofDamaged++;
				} else {
					if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
						leftBoundary = tempLocation.getEndOffset();
						lastAppendableBeforeChange = tempFriend;
					}
					if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
						rightBoundary = tempLocation.getOffset();
						lastPrependableBeforeChange = tempFriend;
					}
				}
			}
		}
		if (!friendModules.isEmpty()) {
			isControlPossible &= friendModules.get(friendModules.size() - 1).getLocation().getEndOffset() < leftBoundary;
		}

		for (Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext() && !enveloped;) {
			final Definition temp = iterator.next();
			if (temp.getParentGroup() == null) {
				final Location tempLocation = temp.getLocation();
				final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
				if (tempLocation.equals(cumulativeLocation) && reparser.envelopsDamage(cumulativeLocation)) {
					enveloped = true;
					leftBoundary = cumulativeLocation.getOffset();
					rightBoundary = cumulativeLocation.getEndOffset();
				} else if (reparser.isDamaged(cumulativeLocation)) {
					nofDamaged++;
					if (reparser.getDamageStart() == cumulativeLocation.getEndOffset()) {
						lastAppendableBeforeChange = temp;
					} else if (reparser.getDamageEnd() == cumulativeLocation.getOffset()) {
						lastPrependableBeforeChange = temp;
					}
				} else {
					if (cumulativeLocation.getEndOffset() < damageOffset && cumulativeLocation.getEndOffset() > leftBoundary) {
						leftBoundary = cumulativeLocation.getEndOffset();
						lastAppendableBeforeChange = temp;
					}
					if (cumulativeLocation.getOffset() > damageEndOffset && cumulativeLocation.getOffset() < rightBoundary) {